<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var num = parseInt(prompt('请任意输入三个数', 156)),
            ge = num % 10,
            shi = parseInt(num / 10) % 10,
            bai = parseInt(num / 100),
            sum = ge + shi + bai;

        alert('各数位的和为:' + sum)
    </script>
</body>

</html>